<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2017/12/24
 * Time: 14:23
 */

namespace Information\Controller;


use Common\Controller\AdminbaseController;
use Common\Model\OptionsModel;

class OptionsController extends AdminbaseController
{
    private $options_model;

    public function __construct()
    {
        parent::__construct();
        $this->options_model = new OptionsModel();
    }

    public function index() {
        if(IS_POST) {
            $data = I('post.');
            $data['option_value'] = htmlspecialchars_decode($data['option_value']);//dump($data);exit;
            if($this->options_model->where(['option_name' => $data['option_name']])->save($data)) {
                $this->success();
            } else {
                //$this->options_model->getLastSql();exit;
                $this->error();
            }
            //dump($data);exit;
        } else {
            $info = $this->options_model->where(['option_name' => 'website_options'])->find();
            $this->assign('info', $info);//dump($info);
            $this->display();
        }

    }
}